//
//  AddVideoTableViewCell.m
//  MIDI
//
//  Created by 王禹丞 on 15/10/20.
//  Copyright (c) 2015年 QXSX. All rights reserved.
//

#import "AddVideoTableViewCell.h"

@interface AddVideoTableViewCell()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *videoUrl;
@property (copy, nonatomic) NSString *placeHolder;

@end

@implementation AddVideoTableViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"AddVideoTableViewCell";
    
    AddVideoTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
       
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AddVideoTableViewCell" owner:nil options:nil]firstObject] ;
        
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    return cell;
}


-(void)awakeFromNib{
    
    self.videoUrl.delegate = self;
    self.placeHolder = @"请输入视频地址";
    
}

//textView编辑开始的时候
- (void)textViewDidBeginEditing:(UITextView *)textView{
    
    textView.text = @"";
    
}

//textView编辑结束的时候
- (void)textViewDidEndEditing:(UITextView *)textView{
    
    if ([textView.text isEqualToString:@""]){
        textView.text = self.placeHolder;
    }
    
    if ([self.delegate respondsToSelector:@selector(uploadVideoUrl:)]) {
        
        [self.delegate uploadVideoUrl:textView.text];
    }
}


@end



